﻿@using Hiwjcn.Web.Controllers;

@{
    Layout = null;
    var list = ViewData["list"] as List<TBColumns>;
    if (ValidateHelper.IsPlumpList(list))
    {
        foreach (var col in list)
        {
            col.Field = ConvertHelper.GetString(col.Field);
            col.Type = ConvertHelper.GetString(col.Type).ToLower();
            col.Key = ConvertHelper.GetString(col.Key).ToUpper();

            if (col.Key == "PRI")
            {
                <div>[Id(0, Name = "@(col.Field)", Column = "@(col.Field)")]</div>
                <div>[Generator(1, Class = ModelConfig.IdEntity)]</div>
            }
            else
            {
                <div>[Property(Column = "@(col.Field)")]</div>
            }
            var tp = "string";
            if (col.Type.IndexOf("int") >= 0) { tp = "int"; }
            if (col.Type.IndexOf("double") >= 0) { tp = "double"; }
            if (col.Type.IndexOf("decimal") >= 0) { tp = "decimal"; }
            if (col.Type.IndexOf("float") >= 0) { tp = "float"; }
            if (col.Type.IndexOf("date") >= 0) { tp = "DateTime"; }

            <div>
                public virtual @(tp) @(col.Field) { get; set; }
            </div>
        }
    }
}

